<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%ns_email}}".
 *
 * @property integer $id
 * @property integer $user_id
 * @property string $title
 * @property string $content
 * @property string $receiver
 * @property string $date
 *
 * @property NsUser $user
 */
class Email extends \yii\db\ActiveRecord
{
    public $grade;
    public $department;
    public $professional;
    public $class;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%ns_email}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['user_id', 'title', 'content', 'receiver'], 'required'],
            [['user_id'], 'integer'],
            [['content'], 'string'],
            [['date'], 'safe'],
            [['title'], 'string', 'max' => 200],
            [['receiver'], 'string', 'max' => 500]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('Message', 'ID'),
            'user_id' => Yii::t('Message', 'User ID'),
            'title' => Yii::t('Message', 'Title'),
            'content' => Yii::t('Message', 'Content'),
            'receiver' => Yii::t('Message', 'Receiver'),
            'date' => Yii::t('Message', 'Date'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['user_id' => 'user_id']);
    }
}
